﻿using System.Collections;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace SiteFox.WebParts.Standard
{
    [AspNetHostingPermission(SecurityAction.Demand,
      Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand,
      Level = AspNetHostingPermissionLevel.Minimal)]

    public class ImageWP : WebPart
    {
        Image _Image;

        private string _ImageUrl = "";
        [Personalizable(true)]
        [WebBrowsable(true)]
        [WebDescription("Enter image url")]
        [WebDisplayName("Image url")]
        public string ImageUrl
        {
            get { return _ImageUrl; }
            set { _ImageUrl = value; }
        }

        private string _ImageAlternateText = "";
        [Personalizable(true)]
        [WebBrowsable(true)]
        [WebDescription("Alternate text")]
        [WebDisplayName("Alternate text")]
        public string ImageAlternateText
        {
            get { return _ImageAlternateText; }
            set { _ImageAlternateText = value; }
        }

        private string _ImageClass = "";
        [Personalizable(true)]
        [WebBrowsable(true)]
        [WebDescription("ImageClass")]
        [WebDisplayName("ImageClass")]
        public string ImageClass
        {
            get { return _ImageClass; }
            set { _ImageClass = value; }
        }

        protected override void CreateChildControls()
        {
            Controls.Clear();
            _Image = new Image();
            _Image.CssClass = _ImageClass;
            _Image.AlternateText = _ImageAlternateText;
            _Image.ImageUrl = _ImageUrl;
            Controls.Add(_Image);
        }
    }
}
